package com.falm.picturebackend.repository.impl;

import com.falm.picturebackend.dao.FileDODao;
import com.falm.picturebackend.entity.BO.FilesBO;
import com.falm.picturebackend.entity.DO.FilesDO;
import com.falm.picturebackend.entity.convert.FilesConvert;
import com.falm.picturebackend.repository.FileRepository;
import org.springframework.stereotype.Repository;

import javax.annotation.Resource;
import java.util.List;

@Repository
public class FileRepositoryImpl implements FileRepository {

    @Resource
    private FileDODao fileDODao;

    @Override
    public FilesBO getFileByFullPath(String fullPath) {
        FilesDO filesDO = fileDODao.getFileByFullPath(fullPath);
        return FilesConvert.do2BO(filesDO);
    }

    @Override
    public void batchInsert(List<FilesBO> filesBOList) {
        fileDODao.batchInsert(FilesConvert.bo2DOList(filesBOList));
    }

    @Override
    public List<FilesBO> getAllFileS() {
        return FilesConvert.do2Forest(fileDODao.getAllFile());
    }

    @Override
    public void deleteFileByFullPath(String fullPath) {
        fileDODao.deleteFileByFullPath(fullPath);
    }
}
